package com.second.app.thread.synchroized.D;

/**
 * @Author GYZ
 * <pre>
 *
 * </pre>
 */
public class Service {

    private String usernameParam;

    private String passwordParam;


    public void setUsernamePassword(String username, String password) {
        try {
            String anyString = new String();
            synchronized (anyString) {
                System.out.println("线程为：" + Thread.currentThread().getName() + "在" + System.currentTimeMillis() + "进入同步块");
                usernameParam = username;
                Thread.sleep(300);
                passwordParam = password;
                System.out.println("线程为：" + Thread.currentThread().getName() + "在" + System.currentTimeMillis() + "离开同步块");
            }
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
